<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.js'></script>
</head>

<body>
    <div id='app'>
        <h1>{{count}}</h1>
        <button @click="add">直接累加</button>
        <button @click="decrement($event)">直接累减</button>
        <button @click="addN($event,2)">累加n</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el: '#app',
            data() {
                return {
                    msg: 'hello Vue'
                }
            },
            methods:{
                 /* 如果使用当前函数的时候,没有加括号,则当前事件函数的第一个参数就是event对象 */
                 add(e){
                    console.log(e,'add中的e');
                    this.count++
                 },
                 decrement(e){
                    this.count--;
                 },addN(e,n){
                    this.count+=n
                 }
            }
        })
    </script>
</body>

</html>